package com.yuyou.tas.admin.service.impl;

import com.yuyou.tas.admin.mapper.AuthOrganizationFuncMapper;
import com.yuyou.tas.admin.service.IAuthOrganizationFuncService;
import com.yuyou.tas.service.api.admin.entity.AuthOrganizationFunc;
import com.yuyou.tas.util.tool.Sequence;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class AuthOrganizationFuncServiceImpl implements IAuthOrganizationFuncService{

	@Autowired
	private AuthOrganizationFuncMapper mapper;
	
	@Override
	public int deleteByPrimaryKey(Long id) {
		return mapper.deleteByPrimaryKey(id);
	}

	@Override
	public int insert(AuthOrganizationFunc record) {
		record.setId(Sequence.getSequence().nextId());
		record.setCreateTime(new Date());
		return mapper.insert(record);
	}

	@Override
	public AuthOrganizationFunc selectByPrimaryKey(Long id) {
		return mapper.selectByPrimaryKey(id);
	}

	@Override
	public int updateByPrimaryKeySelective(AuthOrganizationFunc record) {
		return mapper.updateByPrimaryKeySelective(record);
	}

	@Override
	public void delByOrganId(Long organId) {
		mapper.delByOrganId(organId);
	}

	@Override
	public List<Integer> getByOrganId(Long organId) {
		return mapper.getByOrganId(organId);
	}

	@Override
	public boolean hasPermission(Long organId, int type) {
		List<Integer> typeList=mapper.getByOrganId(organId);
		if(typeList.contains(type)){
			return true;
		}		
		return false;
	}

}